package com.hpin.fansea.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hpin.fansea.R;

/**
 * Created by Aaron on 15/9/11.
 */
public class ServiceModuleAdapter extends BaseAdapter {

    private Context ctx;

    public ServiceModuleAdapter(Context ctx) {
        this.ctx = ctx;
    }

    @Override
    public int getCount() {
        return 4;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder = null;

        if (convertView == null) {

            convertView = View.inflate(ctx, R.layout.item_home_module, null);
            viewHolder = new ViewHolder();
            viewHolder.iv_bg = (ImageView) convertView.findViewById(R.id.iv_bg);
            viewHolder.tv_style = (TextView) convertView.findViewById(R.id.tv_style);

            convertView.setTag(viewHolder);

        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
//        viewHolder.iv_delete.setVisibility(View.INVISIBLE);


        switch (position) {

            case 0:

                viewHolder.iv_bg.setBackgroundResource(R.drawable.shape_complaint);
                viewHolder.iv_bg.setImageResource(R.mipmap.icon_housekeeping);
                viewHolder.tv_style.setText(ctx.getResources().getString(R.string.housekeeping));

                break;
//            case 1:
//
//                viewHolder.iv_bg.setBackgroundResource(R.drawable.shape_repair);
//                viewHolder.iv_bg.setImageResource(R.mipmap.icon_wash_car);
//                viewHolder.tv_style.setText(ctx.getResources().getString(R.string.wash_car));
//
//                break;
            case 1:

                viewHolder.iv_bg.setBackgroundResource(R.drawable.shape_pay);
                viewHolder.iv_bg.setImageResource(R.mipmap.icon_wash_clothes);
                viewHolder.tv_style.setText(ctx.getResources().getString(R.string.wash_clothes));

                break;
            case 2:

                viewHolder.iv_bg.setBackgroundResource(R.drawable.shape_guide);
                viewHolder.iv_bg.setImageResource(R.mipmap.icon_express);
                viewHolder.tv_style.setText(ctx.getResources().getString(R.string.express));

                break;
            case 3:

                viewHolder.iv_bg.setBackgroundResource(R.drawable.shape_fansea);
                viewHolder.iv_bg.setImageResource(R.mipmap.icon_house_rent);
                viewHolder.tv_style.setText(ctx.getResources().getString(R.string.house_rent));

                break;
//            case 5:
//
//                viewHolder.iv_bg.setBackgroundResource(R.drawable.shape_surround);
//                viewHolder.iv_bg.setImageResource(R.mipmap.icon_get_water);
//                viewHolder.tv_style.setText(ctx.getResources().getString(R.string.get_water));
//
//                break;

        }

        return convertView;
    }

    private class ViewHolder {
        private ImageView iv_bg;
        private TextView tv_style;
    }
}
